from flask_sqlalchemy import SQLAlchemy
from datetime import datetime

db = SQLAlchemy()

# TODO 自定义模型类

# 用户表
class User(db.Model):
    id = db.Column(db.Integer, autoincrement=True, primary_key=True,comment='ID')
    create_time = db.Column(db.DateTime, default=datetime.now, comment='创建时间')  # 创建时间
    update_time = db.Column(db.DateTime, default=datetime.now, comment='修改时间')
    name = db.Column(db.String(20), comment="姓名")
    mobile = db.Column(db.String(11), comment='手机号')
    sex = db.Column(db.String(11), comment='性别')
    money = db.Column(db.Integer, comment="钱")
    # img = db.Column(db.text, comment="头像")


# 三方登录表
class Sflogin(db.Model):
    id = db.Column(db.Integer, primary_key=True)  # 设置主键, 默认自增
    create_time = db.Column(db.DateTime, default=datetime.now, comment='创建时间')  # 创建时间
    update_time = db.Column(db.DateTime, default=datetime.now, comment='修改时间')
    token = db.Column(db.Text, comment='token')
    user_id = db.Column(db.Integer, comment='用户id')
    sf_id = db.Column(db.String(100), comment='三方id')
    three_name = db.Column(db.String(32), comment='三方登录的名称')

# 寻宠表0
class Seek_avour0(db.Model):
    id = db.Column(db.Integer, autoincrement=True, primary_key=True,comment='ID')
    variety = db.Column(db.String(100), comment="品种")
    sex = db.Column(db.String(10), comment="性别")
    age = db.Column(db.String(50), comment="年龄")
    time = db.Column(db.DateTime, comment="丢失时间")
    location = db.Column(db.String(100), comment="丢失位置")
    contact_way = db.Column(db.String(11), comment="联系方式")
    condition = db.Column(db.Text, comment="丢失情况")
    img = db.Column(db.String(100), comment="宠物近期生活的照片")
    code = db.Column(db.String(50), comment="唯一id")
    user_id = db.Column(db.String(50), comment='user_id')
    state = db.Column(db.Integer, comment="状态（1未审核  2审核中）")

# 寻宠表1
class Seek_avour1(db.Model):
    id = db.Column(db.Integer, autoincrement=True, primary_key=True,comment='ID')
    variety = db.Column(db.String(100), comment="品种")
    sex = db.Column(db.String(10), comment="性别")
    age = db.Column(db.String(50), comment="年龄")
    time = db.Column(db.DateTime, comment="丢失时间")
    location = db.Column(db.String(100), comment="丢失位置")
    contact_way = db.Column(db.String(11), comment="联系方式")
    condition = db.Column(db.Text, comment="丢失情况")
    img = db.Column(db.String(100), comment="宠物近期生活的照片")
    code = db.Column(db.String(50), comment="唯一id")
    user_id = db.Column(db.String(50), comment='user_id')
    state = db.Column(db.Integer, comment="状态（1未审核  2审核中）")

# 寻宠表2
class Seek_avour2(db.Model):
    id = db.Column(db.Integer, autoincrement=True, primary_key=True,comment='ID')
    variety = db.Column(db.String(100), comment="品种")
    sex = db.Column(db.String(10), comment="性别")
    age = db.Column(db.String(50), comment="年龄")
    time = db.Column(db.DateTime, comment="丢失时间")
    location = db.Column(db.String(100), comment="丢失位置")
    contact_way = db.Column(db.String(11), comment="联系方式")
    condition = db.Column(db.Text, comment="丢失情况")
    img = db.Column(db.String(100), comment="宠物近期生活的照片")
    code = db.Column(db.String(50), comment="唯一id")
    user_id = db.Column(db.String(50), comment='user_id')
    state = db.Column(db.Integer, comment="状态（1未审核  2审核中）")



class Xun_focus(db.Model):
    id = db.Column(db.Integer, autoincrement=True, primary_key=True, comment='ID')
    create_time = db.Column(db.DateTime, default=datetime.now, comment='创建时间')  # 创建时间
    update_time = db.Column(db.DateTime, default=datetime.now, comment='修改时间')
    img = db.Column(db.Text, comment="焦点图")


# 我的宠物
class My_pet(db.Model):
    id = db.Column(db.Integer, autoincrement=True, primary_key=True, comment='ID')
    img = db.Column(db.String(100), comment="宠物照片")
    name = db.Column(db.String(100), comment="昵称")
    sex = db.Column(db.String(10), comment="性别")
    variety = db.Column(db.String(100), comment="品种")
    birthday = db.Column(db.DateTime, comment="生日")
    jy = db.Column(db.String(10), comment="绝育情况")
    bz = db.Column(db.Text, comment="备注")
    user_id = db.Column(db.String(50), comment='user_id')


# 充值表
class Top_up(db.Model):
    id = db.Column(db.Integer, autoincrement=True, primary_key=True, comment='ID')
    create_time = db.Column(db.DateTime, default=datetime.now, comment='创建时间')  # 创建时间
    update_time = db.Column(db.DateTime, default=datetime.now, comment='修改时间')
    user_id = db.Column(db.Integer, comment="用户id")
    money = db.Column(db.DECIMAL(10, 2), default=0, comment='余额')
    status = db.Column(db.Integer, comment='状态：0进行中；1充值成功；2充值失败')
    code = db.Column(db.Text, comment='唯一id')












